package com.corechina.apex_osswords.domain.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.corechina.apex_osswords.domain.entity.CoreProject;
import com.corechina.apex_osswords.domain.vo.CoreProjectVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

/**
 * <p>
 * 项目信息表 Mapper 接口
 * </p>
 *
 * @author cc
 * @since 2022-03-11
 */
@Component
public interface CoreProjectMapper extends BaseMapper<CoreProject> {

    IPage<CoreProjectVo> getList(Page page, @Param("projectType") Integer projectType, @Param("projectName") String projectName, @Param("serviceId") Integer serviceId, @Param("serviceBeginDate") String serviceBeginDate, @Param("serviceEndDate") String serviceEndDate, @Param("enterpriseId") Integer enterpriseId);

    CoreProjectVo getOne(@Param("id") Integer id);

    IPage<CoreProjectVo> getListForWeiXin(Page page, @Param("userId") Integer userId, @Param("seeAll") Integer seeAll, @Param("projectType") Integer projectType, @Param("serviceId") Integer serviceId, @Param("enterpriseId") Integer enterpriseId);

    int getProjectCount(@Param("userId") Integer userId, @Param("enterpriseId") Integer enterpriseId);

    @Update("update core_project set is_del = 1 where id = #{id}")
    int updateIsDel(@Param("id") Integer id);

    @Select("select max(serial_number) from core_project where enterprise_id = #{enterpriseId}")
    String getMaxSerialNumber(@Param("enterpriseId") Integer enterpriseId);

    int getEquipmentCount(@Param("id") Integer id);

    CoreProjectVo getOneForRepairs(@Param("id") Integer id);

    @Select("select * from core_project where serial_number = #{serialNumber}")
    CoreProject getOneBySerialNumber(String serialNumber);


}
